local skel = fk.CreateSkill {
  name = "rmt__renru",
  tags = {Skill.Hidden, Skill.Compulsory},
}

local U = require "packages.utility.utility"

skel:addEffect(U.GeneralAppeared, {
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local current = room.current
    if current and not current.dead then
      room:doIndicate(current, {player})
      if not player.dead and not player.chained then
        player:setChainState(true)
      end
      local targets = {}
      local to = player:getNextAlive()
      if to ~= player and not to.chained then
        table.insert(targets, to)
      end
      to = player:getLastAlive()
      if to ~= player and not to.chained then
        table.insertIfNeed(targets, to)
      end
      if #targets > 0 then
        if #targets > 1 then
          targets = room:askToChoosePlayers(current, {
            targets = targets, max_num = 1, min_num = 1, skill_name = skel.name, cancelable = false,
            prompt = "#rmt__renru-choose:"..player.id
          })
        end
        room:doIndicate(current, targets)
        targets[1]:setChainState(true)
      end
    end
  end,
})

Fk:loadTranslationTable{
  ["rmt__renru"] = "忍辱",
  [":rmt__renru"] = "隐匿，锁定技，你登场后，当前回合角色横置你与你一名邻家。",
  ["#rmt__renru-choose"] = "忍辱：请横置 %src 的一名邻家",
}

return skel
